iT邦幫忙

2024 iThome 鐵人賽

DAY 4
0
AI/ ML & Data

Web仔從數學角度學習 AI/ ML & Data系列 第 4

Day 4 - Web仔從數學角度學習 初始裝備之危🐔分

  • 分享至 

  • xImage
  •  

註:本文同步更新在Notion!(數學公式會比較好閱讀)

每年都會聽到小大一們的哀號,希望微積分可以過

當然也會聽到,學了微積分以後不會用到幹嘛教

今天主要在微分跟矩陣微分,直接進入正題gogo

微分

基本微分公式

  1. 常數項的微分
    https://ithelp.ithome.com.tw/upload/images/20240916/20168898SiqrFZdABW.png

  2. 冪法則 (Power Rule)
    https://ithelp.ithome.com.tw/upload/images/20240916/20168898qDofHJXh1b.png

  3. 指數函數的微分
    https://ithelp.ithome.com.tw/upload/images/20240916/20168898RSuRvGqvup.png

  4. 對數函數的微分
    https://ithelp.ithome.com.tw/upload/images/20240916/20168898y8Uta4t25A.png

  5. 三角函數的微分
    https://ithelp.ithome.com.tw/upload/images/20240916/20168898oko4MrnCby.png

乘法與鏈式法則

  • 乘法法則 (Product Rule)
    https://ithelp.ithome.com.tw/upload/images/20240916/201688989wroiiofHV.png

  • 鏈式法則 (Chain Rule)
    https://ithelp.ithome.com.tw/upload/images/20240916/20168898a3144mVz1a.png
    鏈式法則在機器學習中反向傳播算法的推導中極其重要。


矩陣微分(Matrix Calculus)

矩陣微分是線性代數和微分計算的結合,特別是在處理向量和矩陣形式的函數時極為有用。它在機器學習中的優化過程中被廣泛使用,例如在反向傳播算法中計算權重的梯度時,矩陣微分很常使用到。

標量對向量的微分
https://ithelp.ithome.com.tw/upload/images/20240916/20168898HqtxuV6ty1.png
這樣的微分結果可以直接應用於機器學習中的最小二乘法。

向量對向量的微分
https://ithelp.ithome.com.tw/upload/images/20240916/20168898bjg5ZATYPH.png

矩陣對矩陣的微分

https://ithelp.ithome.com.tw/upload/images/20240916/201688983nEfHfxRt1.png

https://ithelp.ithome.com.tw/upload/images/20240916/20168898x5WxVnkQDD.png

常見矩陣微分公式

https://ithelp.ithome.com.tw/upload/images/20240916/20168898W9TrlhTDqO.png

https://ithelp.ithome.com.tw/upload/images/20240916/20168898A7KL27D1lx.png

https://ithelp.ithome.com.tw/upload/images/20240916/201688984ZXtWNkUzF.png

https://ithelp.ithome.com.tw/upload/images/20240916/20168898k043pAEUaW.png


應用:機器學習中的梯度下降法

在機器學習中,我們經常需要對損失函數(如均方誤差、交叉熵等)進行優化。梯度下降法是一種常用的優化技術,它基於損失函數對權重矩陣的微分(即梯度)。矩陣微分在這裡至關重要,因為我們處理的數據往往是向量或矩陣形式。

https://ithelp.ithome.com.tw/upload/images/20240916/20168898k8ifihNSKE.png


微積分就提到微分和矩陣微分,在處理高維數據、優化模型和計算梯度時就比較容易上手。無論是經典的二次型函數還是複雜的矩陣對矩陣的微分,都有助於我們了解模型的內在運行機制。

接下來會討論到 最佳化理論跟統計,我不希望大概把數學當成無聊的一項,所以我盡量會有趣(?)


https://ithelp.ithome.com.tw/upload/images/20240916/201688984yQ5NVEr53.png


上一篇
Day 3 - Web仔從數學角度學習 初始裝備之線性代數(2/2)
下一篇
Day 5 - Web仔從數學角度學習 初始裝備之最佳化理論
系列文
Web仔從數學角度學習 AI/ ML & Data23
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言